/*
 * @Author: cooper
 * @Date: 2025-03-30 21:35:19
 * @Wechat: cmd_develop
 * @Description:
 */
#ifndef BSP_ARM
#define BSP_ARM

#include "common.h"
extern SemaphoreHandle_t arm_finish_sem;
extern QueueHandle_t arm_basic_work_queue;

void ARM_UART_INIT(void);
void ARM_TASK(void);
void ARM_TASK_DEINIT(void);
void ARM_UART_DMA_TX(u16 size);

void ARM_SEND(void);
#define ARM_DATA_SIZE 30

typedef struct
{
    u8 rx_data[ARM_DATA_SIZE]; /*接收数据缓冲区*/
    u16 rx_total;              /*接收数据大小*/
    u8 tx_data[ARM_DATA_SIZE]; /*发送数据缓冲区*/
    u16 tx_total;              /*发送总数据大小*/
} arm_buffer;

extern arm_buffer arm_Buffer;

#define RX_ARM(x) arm_Buffer.rx_data[x]
#define RX_ARM_TOTAL arm_Buffer.rx_total
#define TX_ARM(x) arm_Buffer.tx_data[x]
#define TX_ARM_TOTAL arm_Buffer.tx_total

#define RX_ARM_BUFCLEAR()                      \
    do                                         \
    {                                          \
        for (u16 i = 0; i < RX_ARM_TOTAL; i++) \
        {                                      \
            RX_ARM(i) = 0;                     \
        }                                      \
        RX_ARM_TOTAL = 0;                      \
    } while (0)
#define TX_ARM_BufClear()                      \
    do                                         \
    {                                          \
        for (u16 i = 0; i < TX_ARM_TOTAL; i++) \
        {                                      \
            TX_ARM(i) = 0;                     \
        }                                      \
        TX_ARM_TOTAL = 0;                      \
    } while (0)

#endif
